<?php
	
	// Add RSS links to <head> section
	automatic_feed_links();
	
	// Load jQuery
	if ( !is_admin() ) {
	   wp_deregister_script('jquery');
	   /*wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"), false);*/
	   wp_enqueue_script('jquery');
	}
	
	// Clean up the <head>
	function removeHeadLinks() {
    	remove_action('wp_head', 'rsd_link');
    	remove_action('wp_head', 'wlwmanifest_link');
    }
    add_action('init', 'removeHeadLinks');
    remove_action('wp_head', 'wp_generator');
    
	// Declare sidebar widget zone
    if (function_exists('register_sidebar')) {
    	register_sidebar(array(
    		'name' => 'Sidebar Widgets',
    		'id'   => 'sidebar-widgets',
    		'description'   => 'These are widgets for the sidebar.',
    		'before_widget' => '<div id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</div>',
    		'before_title'  => '<h2>',
    		'after_title'   => '</h2>'
    	));
    }
    // Disable the Admin Bar.
    add_filter( 'show_admin_bar', '__return_false' );
    //create menu
    if(function_exists('register_nav_menus')){
        register_nav_menus(array(
            'main_nav'=>'Main Menu',
            'bottom_nav'=>'Bottom Menu',
            'support_nav'=>'Support Menu',
            'project_nav'=>'Project Menu',
        ));
    }
    require_once('inc/twitter_bootstrap_nav.php');

    //create thumbnail
    if(function_exists('add_theme_support')){
        add_theme_support('post-thumbnails');
    }

    //Add Limit Excerpt
    function get_limit_excerpt($limit, $source = null){
        if($source == "content" ? ($excerpt = get_the_content()) : ($excerpt = get_the_excerpt()));
        $excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
        $excerpt = strip_shortcodes($excerpt);
        $excerpt = strip_tags($excerpt);
        $excerpt = substr($excerpt, 0, $limit);
        $excerpt = substr($excerpt, 0, strripos($excerpt, " "));
        $excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
        $excerpt = $excerpt.'...';
        return $excerpt;
    }

    //Add Limit Content
    function get_limit_content($limit, $source = null){
        if($source == "content" ? ($excerpt = get_the_content()) : ($excerpt = get_the_content()));
        $excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
        $excerpt = strip_shortcodes($excerpt);
        $excerpt = strip_tags($excerpt);
        $excerpt = substr($excerpt, 0, $limit);
        $excerpt = substr($excerpt, 0, strripos($excerpt, " "));
        $excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
        $excerpt = $excerpt.'...';
        return $excerpt;
    }

   /* //Register Session
    function register_my_session()
    {
        if( !session_id() )
        {
            session_start();
        }
    }

    add_action('init', 'register_my_session');*/

?>